- merged = local_assigns.fetch(:merged, false)
- commit = @repository.commit(branch.dereferenced_target)
- related_merge_request = @related_merge_requests[branch.name]&.first
- mr_status = merge_request_status(related_merge_request)
- is_default_branch = branch.name == @repository.root_ref
- pipeline = commit_status&.subject

%li{ class: "branch-item !gl-flex !gl-items-center js-branch-item js-branch-#{branch.name} !gl-pr-3", data: { name: branch.name, testid: 'branch-container', qa_name: branch.name } }
  .branch-info{ class: '!gl-overflow-visible' }
    .gl-flex.gl-items-center
      = link_to project_tree_path(@project, branch.name, ref_type: 'heads'), class: 'gl-link item-title str-truncated-100 ref-name', data: { testid: 'branch-link' } do
        = branch.name
      = clipboard_button(text: branch.name, title: _("Copy branch name"))
      - if is_default_branch
        = gl_badge_tag s_('DefaultBranchLabel|default'), { variant: :info }, { class: 'gl-ml-2' }
      - if protected_branch?(@project, branch)
        = gl_badge_tag s_('Branches|protected'), { variant: :neutral }, { class: 'gl-ml-2' }

      = render_if_exists 'projects/branches/diverged_from_upstream', branch: branch

    .gl-truncate.-gl-my-2.-gl-ml-2
      - if commit
        = render 'projects/branches/commit', commit: commit, project: @project, class_name: 'gl-p-2'
      - else
        .gl-text-sm.gl-text-subtle.gl-p-2= s_('Branches|Can’t find HEAD commit for this branch')

  - if branch.name != @repository.root_ref
    .js-branch-divergence-graph

  .pipeline-status.gl-hidden{ class: '@md/panel:gl-block' }<
    - if commit_status
      = render 'ci/status/icon', status: commit_status
    - elsif show_commit_status
      .gl-inline-flex.gl-align-middle.gl-mr-3
        %svg.s16

  .right-block.gl-flex.gl-items-center{ class: '@md/panel:gl-justify-end' }
    .gl-mr-3
      - if mr_status.present? && can?(current_user, :read_merge_request, related_merge_request)
        .issuable-reference.gl-flex.gl-justify-end.gl-overflow-hidden
          = gl_badge_tag({ icon: mr_status[:icon], variant: mr_status[:variant], href: merge_request_path(related_merge_request) },
            { class: 'gl-truncate', title: mr_status[:title], data: { toggle: 'tooltip', container: 'body' } }) do
            .gl-truncate
              = issuable_reference(related_merge_request)

      - elsif mr_status.nil? && create_mr_button?(from: branch.name, source_project: @project)
        = render Pajamas::ButtonComponent.new(icon: 'merge-request', href: create_mr_path(from: branch.name, source_project: @project), button_options: { class: 'has-tooltip', title: _('New merge request') }) do
          = _('New')

    = render 'projects/buttons/download', project: @project, ref: branch.name, ref_type: :heads, pipeline: pipeline, css_class: '!gl-mr-2'

    .gl-w-7
      - if !is_default_branch
        .js-branch-more-actions{ data: {
            branch_name: branch.name,
            default_branch_name: @repository.root_ref,
            can_delete_branch: user_access(@project).can_delete_branch?(branch.name).to_s,
            is_protected_branch: protected_branch?(@project, branch).to_s,
            merged: merged.to_s,
            compare_path: project_compare_index_path(@project, from: @repository.root_ref, to: branch.name),
            delete_path: project_branch_path(@project, branch.name),
        } }
